/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package xq.gwt.ui.widgets.property;

import com.smartgwt.client.widgets.form.fields.PasswordItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
import xq.gwt.mvc.controller.PasswordPropertyController;
import xq.gwt.mvc.model.PasswordPropertyModel;
import xq.gwt.mvc.view.PasswordPropertyView;


/**
 *
 * @author admin
 */
public class PasswordItemPropertyPresenter extends FormItemPropertyPresenter implements PasswordPropertyView{
    protected PasswordItem passwordItem;
	protected PasswordPropertyController controller;

    public PasswordItemPropertyPresenter(PasswordItem textItem){    
    	this.passwordItem = textItem;
    	formItem = textItem;
        init();
        
    }
    
    public PasswordItemPropertyPresenter(){    	
    	passwordItem = new PasswordItem();    	
    	formItem = passwordItem;
    	init();
    }

	protected void init() {		
		formItem.addChangedHandler(new ChangedHandler() {
			@Override
			public void onChanged(ChangedEvent event) {
				notifyViewChangedListeners();

			}
		});		
		controller = new PasswordPropertyController(this);	
		super.controller = controller;
	}
    
    public void setText(String text) {
        passwordItem.setValue(text);       
    }

    public String getText() {
        return String.valueOf(passwordItem.getValue());
    }
    
    public void setModel(PasswordPropertyModel model){
    	controller.setPropertyModel(model);
    }
    
    
    public PasswordItem getPasswordItem() {
		return passwordItem;
	}

}
